import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/application/device_type_tree_new_entity.dart';

DeviceTypeTreeNewEntity $DeviceTypeTreeNewEntityFromJson(Map<String, dynamic> json) {
  final DeviceTypeTreeNewEntity deviceTypeTreeNewEntity = DeviceTypeTreeNewEntity();
  final int? companyId = jsonConvert.convert<int>(json['companyId']);
  if (companyId != null) {
    deviceTypeTreeNewEntity.companyId = companyId;
  }
  final List<DeviceTypeTreeNewTreeSelects>? treeSelects = (json['treeSelects'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DeviceTypeTreeNewTreeSelects>(e) as DeviceTypeTreeNewTreeSelects).toList();
  if (treeSelects != null) {
    deviceTypeTreeNewEntity.treeSelects = treeSelects;
  }
  final String? companyName = jsonConvert.convert<String>(json['companyName']);
  if (companyName != null) {
    deviceTypeTreeNewEntity.companyName = companyName;
  }
  return deviceTypeTreeNewEntity;
}

Map<String, dynamic> $DeviceTypeTreeNewEntityToJson(DeviceTypeTreeNewEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['companyId'] = entity.companyId;
  data['treeSelects'] = entity.treeSelects.map((v) => v.toJson()).toList();
  data['companyName'] = entity.companyName;
  return data;
}

extension DeviceTypeTreeNewEntityExtension on DeviceTypeTreeNewEntity {
  DeviceTypeTreeNewEntity copyWith({
    int? companyId,
    List<DeviceTypeTreeNewTreeSelects>? treeSelects,
    String? companyName,
  }) {
    return DeviceTypeTreeNewEntity()
      ..companyId = companyId ?? this.companyId
      ..treeSelects = treeSelects ?? this.treeSelects
      ..companyName = companyName ?? this.companyName;
  }
}

DeviceTypeTreeNewTreeSelects $DeviceTypeTreeNewTreeSelectsFromJson(Map<String, dynamic> json) {
  final DeviceTypeTreeNewTreeSelects deviceTypeTreeNewTreeSelects = DeviceTypeTreeNewTreeSelects();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    deviceTypeTreeNewTreeSelects.id = id;
  }
  final String? label = jsonConvert.convert<String>(json['label']);
  if (label != null) {
    deviceTypeTreeNewTreeSelects.label = label;
  }
  final String? typeCode = jsonConvert.convert<String>(json['typeCode']);
  if (typeCode != null) {
    deviceTypeTreeNewTreeSelects.typeCode = typeCode;
  }
  final int? sort = jsonConvert.convert<int>(json['sort']);
  if (sort != null) {
    deviceTypeTreeNewTreeSelects.sort = sort;
  }
  final int? parentId = jsonConvert.convert<int>(json['parentId']);
  if (parentId != null) {
    deviceTypeTreeNewTreeSelects.parentId = parentId;
  }
  return deviceTypeTreeNewTreeSelects;
}

Map<String, dynamic> $DeviceTypeTreeNewTreeSelectsToJson(DeviceTypeTreeNewTreeSelects entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['label'] = entity.label;
  data['typeCode'] = entity.typeCode;
  data['sort'] = entity.sort;
  data['parentId'] = entity.parentId;
  return data;
}

extension DeviceTypeTreeNewTreeSelectsExtension on DeviceTypeTreeNewTreeSelects {
  DeviceTypeTreeNewTreeSelects copyWith({
    int? id,
    String? label,
    String? typeCode,
    int? sort,
    int? parentId,
  }) {
    return DeviceTypeTreeNewTreeSelects()
      ..id = id ?? this.id
      ..label = label ?? this.label
      ..typeCode = typeCode ?? this.typeCode
      ..sort = sort ?? this.sort
      ..parentId = parentId ?? this.parentId;
  }
}